package com.ruoyi.hqfinance.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.hqfinance.domain.HqNewSheetRebate;
import com.ruoyi.hqfinance.domain.vo.HqNewSheetRebateByDayVo;
import com.ruoyi.hqfinance.service.HqNewSheetRebateService;
import com.ruoyi.logistic.domain.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/hq/newSheetRebate")
@Api(tags = "总部财务-新面单返利报表")
public class HqNewSheetRebateController {
    @Autowired
    private HqNewSheetRebateService hqNewSheetRebateService;

    @ApiOperation("汇总")
    @PostMapping("/collect")
    public R collectDay(@RequestBody HqNewSheetRebateByDayVo vo){
        if (vo.getStartTime() == null || vo.getEndTime() == null || vo.getCollectType() == null || vo.getNetworkNameId() == null || vo.getObjectType() == null){
            return R.fail("请输入必要的查询字段！");
        }
        List<HqNewSheetRebate> rebates = hqNewSheetRebateService.collect(vo);
        if (rebates == null || rebates.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(rebates));
        }
    }


}
